import request from '../utils/request';
import { applicationItemData } from './application';
import { subjectItemData } from './subject';
const url = 'http://localhost:8080/progress';

export interface progressItemData {
    progressId : number;
    progressState : string;
    applicationId : number;
    subjectId : number;
    application : applicationItemData;
    subject : subjectItemData;
}

export const fetchData = () => {
    return request({
        url: './mock/table.json',
        method: 'get'
    });
};

export const getDataByStudentId = (studentId : number) => {
    console.log(url+'/findByStudentID/'+studentId);
    return request({
        url: url+'/findByStudentID/'+studentId,
        method: 'get'
    });
};

export const fetchRoleData = () => {
    return request({
        url: './mock/role.json',
        method: 'get'
    });
};

export const findApplicationAndExam = (studentId : number) =>{
    return request({
        url: url+`/findApplicationAndExam/${studentId}`,
        method: 'get'
    });
}

export const findAllProgress = () =>{
    return request({
        url: url+`/findAllProgress`,
        method: 'get'
    });
}

export const updateProgress = (progress : progressItemData) =>{
    return request({
        url: url+`/updateProgress`,
        method: 'post',
        data : progress,
    });
}

export const addProgress = (progress : progressItemData) =>{
    return request({
        url: url+`/addProgress`,
        method: 'post',
        data : progress,
    });
}